<extend name="Layout/ins_page"/>
<block name="content">
    {:W('PageHeader/adv_search',array('name'=>'车辆搜索','search'=>'M'))}
    <form method="post" name="form_adv_search" id="form_adv_search">
        <div class="adv_search panel panel-default  hidden" id="adv_search">
            <div class="panel-heading">
                <div class="row">
                    <h4 class="col-xs-6">高级搜索</h4>

                    <div class="col-xs-6 text-right">
                        <a class="btn btn-sm btn-info" onclick="submit_adv_search();">搜索</a>
                        <a class="btn btn-sm " onclick="close_adv_search();">关闭</a>
                    </div>
                </div>
            </div>
            <div class="panel-body">
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label" for="carNum">车牌号：</label>

                    <div class="col-sm-8">
                        <input class="form-control" type="text" id="carNum" name="carNum">
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label" for="carType">车型：</label>

                    <div class="col-sm-8">
                        <input class="form-control" type="text" id="carType" name="carType">
                    </div>
                </div>

                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label" for="color">车身颜色：</label>

                    <div class="col-sm-8">
                        <input class="form-control" type="text" id="color" name="color">
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label" for="register_time">记录时间：</label>

                    <div class="col-sm-8">
                        <div class="input-daterange input-group">
                            <input type="text" class="input-sm form-control text-center" name="beginTime"
                                   readonly="readonly"/>
                            <span class="input-group-addon">-</span>
                            <input type="text" class="input-sm form-control text-center" name="endTime"
                                   readonly="readonly"/>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <div >
        <table data-toggle="table"    data-pagination="true"  data-page-list="[5,10,15]" data-page-size="5" data-unique-id="id" id="carTable" >
            <thead>
                <tr>

                    <th data-field="id">汽车编号</th>
                    <th data-field="carNum">车牌号</th>
                    <th data-field="carType">车型</th>
                    <th data-field="EngineNum">发动机号</th>
                    <th data-field="DipanNum">底盘号</th>
                    <th data-field="oilCardNum">油卡号</th>
                    <th data-field="oilUse">油耗</th>
                    <th data-field="insurer">保险公司</th>
                    <th data-field="insurePhone">保险电话</th>
                    <th data-field="price">购置价格</th>
                    <th data-field="color">车身颜色</th>
                    <th data-field="make">生产厂商</th>
                    <th data-field="price">出厂日期</th>
                    <th data-field="struct">结构特点</th>

                    <th data-field="motDate">年检时间</th>
                    <th data-field="state">状态</th>
                    <th data-field="hander" 	data-width="105" data-align="center">操作</th>
                </tr>
            </thead>

            <tbody>


               <volist name="carList" id="car">
                   <tr >

                       <volist name="car" id="carItem" >

                               <if condition="($key eq 'registerdate') OR ($key eq 'mot') OR ($key eq 'motdistance')">

                               <elseif condition="$key eq 'motdate'"/>
                                   <td>{$carItem}
                                       <if condition="$car['mot'] eq true"> <p class="text-danger">距离年检日期还有{$car['motdistance']}天</p></if>
                                   </td>


                               <else/>
                                   <td>
                                       {$carItem}
                                   </td>
                               </if>

                       </volist>
                       <td >
                           <if condition="$auth['admin']">
                               <a class="btn btn-danger delete btn-xs" carId="{$car['id']}" style="margin-top: 2px;margin-bottom: 2px;" >删除</a>
                               <a class="btn btn-danger edit btn-xs" carId="{$car['id']}" style="margin-top: 2px;margin-bottom: 2px;" >编辑</a>
                           </if>
                           <a class="btn btn-danger  btn-xs state"  carId="{$car['id']}" style="margin-top: 2px;margin-bottom: 2px;" >状态</a>
                           <a class="btn btn-danger  btn-xs" style="visibility: hidden;"  carId="{$car['id']}" style="margin-top: 2px;margin-bottom: 2px;" >空空</a>
                           <!--<div style="margin-top: 5px;padding-left: 2px;">-->
                               <!--<if condition="$car['mot'] eq true"> <a class="btn btn-danger notify btn-xs pull-left" carId="{$car['id']}"  >通知</a></if>-->
                           <!--</div>-->
                       </td>
                   </tr>

               </volist>

            </tbody>
        </table>
    </div>

</block>
<block name="js">
    <script type="text/javascript">
        $(document).ready(function () {
            set_return_url();
             $("#form_search .btn-info").after("<a class='btn btn-sm btn-danger' title='全部显示' href='"+"{:U('showCarInfoList')}"+"'><i class='fa fa-navicon'></i></a>");



            $("#form_search input").attr("placeholder","输入车牌号查询");
            $("#form_search .input-group").width("300");

            $(".edit").on("click",function(event){
                winopen("{:U('editCarById')}"+"?id="+$(this).attr('carId'),704,570);
                $(".myFrame").attr("scrolling","yes");
            });

            $(".delete").on("click",function(event){
                var me = $(this);
                ui_confirm('确定要删除吗?', function() {
                    var url = "{:U('Home/Car/deleteCarById')}";
                    $.getJSON(url, {id: me.attr('carId')}, function (data) {
                        if (data.status) {
                            ui_alert(data.info, function () {
                                parent.location.reload(true);
                                myclose();
                            });
                        } else {
                            ui_error(data.info);
                        }
                    });
                });
            });

            $(".notify").on("click",function(){
                winopen("{:U('getStaff')}"+"?carId="+$(this).attr('carId'),1000,570);
                $(".myFrame").attr("scrolling","yes");
            });

            $(".state").on("click",function(){
                winopen("{:U('getStateLog')}"+"?carId="+$(this).attr('carId'),1000,570);
                $(".myFrame").attr("scrolling","yes");
            });

        });
    </script>
</block>